// route_notifier.dart

import 'package:flutter_riverpod/flutter_riverpod.dart';

class RouteNotifier extends StateNotifier<RouteState> {
  RouteNotifier() : super(const RouteState());

  void updateNavigationState(bool canPop) {
    state = state.copyWith(
        showBackButton: canPop, routeDepth: canPop ? state.routeDepth + 1 : 0);
  }
}

class RouteState {
  final bool showBackButton;
  final int routeDepth;

  const RouteState({this.showBackButton = false, this.routeDepth = 0});

  RouteState copyWith({bool? showBackButton, int? routeDepth}) {
    return RouteState(
        showBackButton: showBackButton ?? this.showBackButton,
        routeDepth: routeDepth ?? this.routeDepth);
  }
}
